home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / intoids.lha / Intoids 1.0 / Source / Intoids.h < prev    next >
C/C++ Source or Header  |  1997-02-12  |  8KB  |  216 lines

  1. #ifndef LIBRARIES_INTOIDS_H
  2. #define LIBRARIES_INTOIDS_H 1
  3.  
  4. /******************************************************************************
  5.  * $Header: Big:Programming/C/Intoids/Library/RCS/Intoids.h,v 1.16 1997/02/12 16:47:30 AGMS Exp $
  6.  *
  7.  * Datatype declarations for intoids.library - An Amiga runtime shared code
  8.  * library for efficiently handling large and small integer values using
  9.  * pointer sized data fields.
  10.  *
  11.  * Look in Intoids.c for documentation, e-mail addresses and credits.
  12.  *
  13.  * Modifications for storing smaller integers in 32 bit values and conversion
  14.  * to an Amiga library copyright © 1996 by Alexander G. M. Smith.
  15.  * Original long integer code copyright © 1988 Free Software Foundation.
  16.  *
  17.  * This library is free software; you can redistribute it and/or
  18.  * modify it under the terms of the GNU Library General Public
  19.  * License as published by the Free Software Foundation; either
  20.  * version 2 of the License, or (at your option) any later version.
  21.  *
  22.  * This library is distributed in the hope that it will be useful,
  23.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  25.  * Library General Public License for more details.
  26.  *
  27.  * You should have received a copy of the GNU Library General Public
  28.  * License along with this library; if not, write to the Free
  29.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  30.  *
  31.  * $Log: Intoids.h,v $
  32.  * Revision 1.16  1997/02/12  16:47:30  AGMS
  33.  * Added header stuff for AGMS Portable Integer Format functions.
  34.  *
  35.  * Revision 1.15  1997/01/14  14:53:58  AGMS
  36.  * Increased number of printable digits (and stack usage) to 1000.
  37.  *
  38.  * Revision 1.14  1997/01/12  12:30:48  AGMS
  39.  * Rearranged stuff so that it fits in with the standard Amiga C compiler
  40.  * include directory structure (prototypes and headers in separate files).
  41.  *
  42.  * Revision 1.13  1996/12/29  09:27:53  AGMS
  43.  * *** empty log message ***
  44.  *
  45.  * Revision 1.12  1996/12/28  13:35:45  AGMS
  46.  * Added Absolute value.
  47.  *
  48.  * Revision 1.11  1996/12/28  13:20:13  AGMS
  49.  * Added SignOfIntoid function, changed comparison result to be +-1.
  50.  *
  51.  * Revision 1.10  1996/12/26  13:24:03  AGMS
  52.  * Added NegateIntoid function.
  53.  *
  54.  * Revision 1.9  1996/12/17  17:08:26  AGMS
  55.  * Need a long, not an int return value for comparisons.
  56.  *
  57.  * Revision 1.8  1996/12/17  15:54:24  AGMS
  58.  * Added function for comparing intoids.
  59.  *
  60.  * Revision 1.7  1996/12/07  15:59:52  AGMS
  61.  * *** empty log message ***
  62.  *
  63.  * Revision 1.6  1996/12/04  16:56:16  AGMS
  64.  * Added CopyIntoid function.
  65.  *
  66.  * Revision 1.5  1996/12/03  16:18:37  AGMS
  67.  * Changed AsciiToIntoid to be more like the UNIX equivalent.
  68.  *
  69.  * Revision 1.4  1996/11/28  16:05:26  AGMS
  70.  * Added error strings by number, some other stuff.
  71.  *
  72.  * Revision 1.3  1996/11/21  16:16:18  AGMS
  73.  * Now compiles, but doesn't have any guts yet.
  74.  *
  75.  * Revision 1.2  1996/11/18  17:24:36  AGMS
  76.  * Whittled down to just the basic functions, added RecycleMe arguments.
  77.  *
  78.  * Revision 1.1  1996/11/14  18:00:57  AGMS
  79.  * Initial revision
  80.  */
  81.  
  82. #ifndef EXEC_TYPES_H
  83. #include <exec/types.h>
  84. #endif
  85.  
  86.  
  87. #define IntoidsName "intoids.library"
  88.   /* Name to use when opening the Intoids shared library.  All lower case. */
  89.  
  90.  
  91. #define MAX_INTOID_ASCII_DIGITS 1000
  92.   /* Maximum number of digits that can be output by the Intoid to Ascii
  93.   functions.  The library's internal number conversions use a buffer of this
  94.   size allocated on the calling task's stack, so watch out! */
  95.  
  96.  
  97. #define SmallIntToIntoid(x) ((Intoid) ((((long) (x)) << 1) | 1))
  98.   /* Converts a short integer or char (unsigned or signed) to an Intoid.  Will
  99.   also work for long integers if they aren't larger than 0x3FFFFFFF in
  100.   absolute value.  Use LongToIntoid to properly handle larger longs. */
  101.  
  102.  
  103. #define INTOID_POSITIVE_INFINITY ((Intoid) 6)
  104. #define INTOID_NEGATIVE_INFINITY ((Intoid) 10)
  105.   /* Special magic codes for infinity values as Intoids.  Related to the
  106.   private IntoidSpecialCodes enum and the SpecialCodeToIntoid macro. */
  107.  
  108.  
  109. typedef void * Intoid;
  110.   /* As far as the user sees it, it is an opaque type.  Treat it like
  111.   a pointer to a dynamically allocated object, though it sometimes
  112.   isn't and sometimes is.  A NULL (zero) value Intoid means that an error
  113.   happened (out of memory, divide by zero, etc), an error message can be
  114.   obtained by calling GetLastIntoidErrorMessage (though it may be incorrect if
  115.   other tasks have caused errors since the time your program caused an error).
  116.   Besides storing really big numbers and not-a-number, the Intoids can also
  117.   represent positive and negative infinity. */
  118.  
  119.  
  120. #if __SASC
  121.   #define STACKCALL __stdargs /* Pass arguments on stack, not in registers. */
  122. #else /* Some other compiler, assumes it uses stack by default. */
  123.   #define STACKCALL
  124. #endif
  125.  
  126.  
  127. typedef enum PortIntCallBackOpEnum
  128. {
  129.   PICBOP_READ = 0,
  130.   PICBOP_SEEK = 1,
  131.   PICBOP_WRITE = 2,
  132.   PICBOP_MAX
  133. } PortIntCallBackOp;
  134.   /* The various operations that the callback function can do.  See
  135.   the intoids.library/AGMSPortableIntStreamCallBack autodocs for details. */
  136.  
  137.  
  138. typedef LONG (* STACKCALL PortIntCallBackPntr) (ULONG, APTR, LONG, APTR);
  139.   /* Define the type for a pointer to a callback function that is used for
  140.   reading and writing AGMS Portable Integer numbers to a stream.  See
  141.   the intoids.library/AGMSPortableIntStreamCallBack autodocs for details. */
  142.  
  143.  
  144. typedef enum IntoidStringNumberEnum
  145. {
  146.   MSG_INTOIDS_NOT_A_NUMBER = 0,
  147.     /* Used in ASCII conversions for things that are not a number.  You
  148.     get this when you divide by zero, or run out of memory (the NULL pointer of
  149.     numbers).  Default is "not-a-number". */
  150.  
  151.   MSG_INTOIDS_INFINITY,
  152.     /* Infinity is represented in ASCII as this value.  There can be an
  153.     optional sign ("+" or "-") in front for positive or negative infinity.
  154.     The same string is used when converting infinite values to strings.
  155.     Default is "infinity". */
  156.  
  157.   MSG_INTOIDS_NUMBER_TOO_BIG_TO_PRINT,
  158.     /* Printed when the number is too big for the internal buffers, in other
  159.     words there are more than MAX_INTOID_ASCII_DIGITS digits in the number.
  160.     Default is "(too big to print)". */
  161.  
  162.   MSG_INTOIDS_PRINTING_OUT_OF_MEMORY,
  163.     /* For use when running out of memory when printing a big number.  Default
  164.     is "(out of memory)". */
  165.  
  166.   MSG_INTOIDS_NEW_TOO_BIG,
  167.     /* When something wants more digits than can be created (more than 64K
  168.     digits).  Default is "Attempt to create a number bigger than the maximum
  169.     allowed size.". */
  170.  
  171.   MSG_INTOIDS_INTREP_OUT_OF_MEMORY,
  172.     /* Used when trying to allocate memory for the integer representation (the
  173.     bits themselves) for an Intoid.  Default: "Out of memory for allocating
  174.     Intoid data bits.". */
  175.  
  176.   MSG_INTOIDS_CREDITS,
  177.     /* A long text with the credits for the program, including GNU license
  178.     information. */
  179.  
  180.   MSG_INTOIDS_CONTINUE_SHOWING_ERRORS,
  181.     /* For requestor that asks if it should continue showing error messages.
  182.     Default: "Continue showing intoids.library error messages?". */
  183.  
  184.   MSG_INTOIDS_BAD_INPUT_PARMS,
  185.     /* Bad input parameters passed to some function.  Things like NULL
  186.     pointers or a Base out of range.  Default: "Bad function input
  187.     parameters.". */
  188.  
  189.   MSG_INTOIDS_DIVIDE_BY_ZERO,
  190.     /* Somebody divided by zero.  Default: "Divide by zero.". */
  191.  
  192.   MSG_INTOIDS_PI_READ_ERROR,
  193.     /* Read error.  Default: "Error while reading portable integer data.". */
  194.  
  195.   MSG_INTOIDS_PI_WRITE_ERROR,
  196.     /* Write error.  Default: "Error while writing portable integer data." */
  197.  
  198.   MSG_INTOIDS_PI_SEEK_ERROR,
  199.     /* Seek error.  Default: "Error while seeking in portable integer data." */
  200.  
  201.   MSG_INTOIDS_PI_BAD_FORMAT,
  202.     /* Number is weird, perhaps too big to handle, having an unknown number
  203.     kind, etc.  Default: "Portable integer has unusual format, bad data?" */
  204.  
  205.   MSG_INTOIDS_UNKNOWN_MESSAGE,
  206.     /* Used when an out of range message code is found. */
  207.  
  208.   MSG_INTOIDS_MAX
  209. } IntoidStringNumbers;
  210.   /* To help make strings localized for different languages, this enum of
  211.   string numbers is used rather than the strings themselves.  The
  212.   GetIntoidsMessage function is used for getting the actual string that
  213.   corresponds to the number. */
  214.  
  215. #endif /* LIBRARIES_INTOIDS_H */
  216.